package com.newtouch.bxzs.database.synchronize.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.newtouch.bxzs.common.base.model.CooperationCompanyUser;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.List;

/**
 * 对端用户Mapper:
 *
 * <p>
 * <b>History:</b>
 * <table border="1">
 * <tr>
 * <th>Date</th>
 * <th>Operator</th>
 * <th>Memo</th>
 * </tr>
 * <tr>
 * <td>2020/12/30 15:22</td>
 * <td>Amour</td>
 * <td>Create</td>
 * </tr>
 * </table>
 *
 * @author yuanjie
 * @version 1.0.0
 * @since 1.0.0
 */
@Mapper
public interface SystemUserOppositeMapper extends BaseMapper<CooperationCompanyUser>{

    /**
     * 批量插入对端用户数据
     * @param systemUserOpposite 用户信息
     * @return int
     */
    @Insert({"<script>insert into ASSISTANT_COOPERATION_COMPANY_USER(COOPERATION_COMPANY_USER_ID," +
            "COOPERATION_COMPANY_USER_JOB_NUMBER,COOPERATION_COMPANY_USER_NAME,COOPERATION_COMPANY_USER_SEX," +
            "COOPERATION_COMPANY_USER_PHONE,COOPERATION_COMPANY_USER_CERTIFICATE_TYPE,COOPERATION_COMPANY_USER_CERTIFICATE_NUMBER," +
            "COOPERATION_COMPANY_USER_ENTRY_TIME,COOPERATION_COMPANY_USER_WORKING_STATUS,COOPERATION_COMPANY_USER_ADDRESS," +
            "COOPERATION_COMPANY_USER_ORGANIZATION_NAME,COOPERATION_COMPANY_USER_ORGANIZATION_CODE," +
            "COOPERATION_COMPANY_USER_DEPARTMENT_NAME,IS_ENABLE,COOPERATION_COMPANY_USER_INTRODUCTION," +
            "COOPERATION_COMPANY_USER_BIRTHDAY,COOPERATION_COMPANY_USER_EMAIL,IS_DELETE," +
            "CREATE_USER_ID,CREATE_TIME,COOPERATION_COMPANY_USER_NAME_FULL_SPELLING) values" +
            "<foreach collection='list' item='item' separator=',' >"+
            "(REPLACE(uuid(),'-',''),#{item.cooperationCompanyUserJobNumber},#{item.cooperationCompanyUserName}," +
            "#{item.cooperationCompanyUserSex},#{item.cooperationCompanyUserPhone},#{item.cooperationCompanyUserCertificateType}," +
            "#{item.cooperationCompanyUserCertificateNumber},#{item.cooperationCompanyUserEntryTime}," +
            "#{item.cooperationCompanyUserWorkingStatus}," +
            "#{item.cooperationCompanyUserAddress},#{item.cooperationCompanyUserOrganizationName}," +
            "#{item.cooperationCompanyUserOrganizationCode}," +
            "#{item.cooperationCompanyUserDepartmentName},1," +
            "#{item.cooperationCompanyUserIntroduction},#{item.cooperationCompanyUserBirthday},#{item.cooperationCompanyUserEmail}," +
            "0,#{item.createUserId}," +
            "#{item.createTime},#{item.cooperationCompanyUserNameFullSpelling})" +
            "</foreach>" +
            "ON DUPLICATE KEY UPDATE" +
            " UPDATE_USER_ID = values(CREATE_USER_ID)</script>"})
    int addSystemUserOpposite(@Param("list") List<CooperationCompanyUser> systemUserOpposite);
}
